/*
Complie:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe compress.cs
or
C:\Windows\Microsoft.NET\Framework64\v3.5\csc.exe compress.cs
Usage:
compress.exe Demo.exe
*/


using System;
using System.IO;
using System.IO.Compression;

namespace PELoader
{
    class Program
    {
        public static string Compress(byte[] fi)
        {
            using (MemoryStream outFile = new MemoryStream())
            {
                using (GZipStream gzip = new GZipStream(outFile, CompressionMode.Compress, true))
                {
                    gzip.Write(fi, 0, fi.Length);
                }
                string b64 = Convert.ToBase64String(outFile.ToArray());
                StreamWriter StreamW = new StreamWriter(@"Comprocessed.b64");
                StreamW.Write(b64);
                StreamW.Close();
                return b64;

            }
        }
        public static void Main(string[] args)
        {
            if(args.Length == 0)
            {
                Console.Write("[!]Args error\r\n[!]Input Eg: c:\\Test\\demo.exe");
                return;
            }
            byte[] FileDate = File.ReadAllBytes(args[0].ToString());
            string CompressData = Compress(FileDate);
            Console.Write("[+]compressed data save to: C:\\Test\\Comprocessed.b64\r\n");
            return;
        }
    }
}